/*
 *  Copyright 2004 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.service.core;

import com.blandware.atleap.common.util.ApplicationResourceStorage;
import com.blandware.atleap.common.util.PartialCollection;
import com.blandware.atleap.common.util.QueryInfo;
import com.blandware.atleap.model.core.ApplicationResource;
import com.blandware.atleap.model.core.ContentLocale;
import com.blandware.atleap.service.exception.BeanNotFoundException;

/**
 * <p>Business Delegate (Proxy) Interface to handle communication between web and
 * persistence layer.
 * </p>
 * <p><a href="ApplicationResourceManager.java.html"><i>View Source</i></a>
 * </p>
 *
 * @author Sergey Zubtsovskiy <a href="mailto:sergey.zubtsovskiy@blandware.com">&lt;sergey.zubtsovskiy@blandware.com&gt;</a>
 * @version $Revision: 1.5 $ $Date: 2006/08/03 10:07:40 $
 */
public interface ApplicationResourceManager extends BaseManager {

	/**
	 * Loads resources from file system and deletes those of them that are not in
     * the file system but still exist in the persistent storage. This can also
     * 'roll back' values of resources in persistent storage to those that are
     * in filesystem.
	 *
	 * @param overrideDynamicValues Whether or not to replace dynamically changed values with static ones from filesystem
     * @return A storage containing loaded application resources
	 */
	public ApplicationResourceStorage loadResources(boolean overrideDynamicValues);

	/**
	 * Loads resource bundle for specified locale
	 *
	 * @param locale Locale to load resources for
	 * @return Bundle containing messages for specified locale
	 */
	public ApplicationResourceStorage.Bundle loadBundle(ContentLocale locale);

	/**
	 * Drops all resources for locale with specified identifier
	 *
	 * @param localeIdentifier Identifier of locale to flush bundle
	 */
	public void dropBundle(String localeIdentifier);

	/**
	 * Retrieves application resource object with specified key and locale
	 *
	 * @param key              Key of resource to retrieve
	 * @param localeIdentifier Identifier of locale
	 * @return Application resource object or null if none is found
	 */
	public ApplicationResource retrieveApplicationResource(String key, String localeIdentifier);

	/**
	 * Updates application resource with specified locale and key if value has been changed. Otherwise, no action is performed.
	 *
	 * @param localeIdentifier Identifier of locale
	 * @param key              Key to associate value with
     * @param value            Value to associate with key
     * @param version          Version of application resource
	 * @throws com.blandware.atleap.service.exception.BeanNotFoundException
	 *          if resource couldn't be found
	 */
	public void updateApplicationResource(String localeIdentifier, String key, String value, Long version) throws BeanNotFoundException;

	// ~ Additional methods ================================================================

	/**
	 * Retrieves filtered/sorted collection of application resources.
	 *
     * @param queryInfo Object that contains information about how to filter and sort data
	 * @return Collection of application resources
	 */
	public PartialCollection listApplicationResources(QueryInfo queryInfo);

}